package tema8.ej05.model;

import java.util.List;

import org.hibernate.Transaction;

import tema8.ej05.model.bo.Pais;

public class PaisDAO extends DAObase {
	public void crearPais(Pais pais) {
		Transaction tx = session.beginTransaction();
		session.persist(pais);
		tx.commit();
	}

	public List<Pais> recuperarPaises() {
		Transaction t = session.beginTransaction();
		@SuppressWarnings("unchecked")
		List<Pais> listaPaises = session.createQuery("from Pais").list();
		t.commit();
		return listaPaises;
	}

	public Pais getPaisPorID(Long idPais) {
		Transaction tx = session.beginTransaction();
		Pais pais=(Pais)session.load(Pais.class,idPais);
		tx.commit();
		return pais;
	}
}
